#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
int t, n, m, L, V, k;
int pos[maxn];
int find_lower(int d, int v, int a) {
    if (a == 0) {
        if (v <= V) return m + 1;
        return lower_bound(pos + 1, pos + m + 1, d) - pos;
    } else if (a < 0) {
        if (v <= V) return m + 1;
        return lower_bound(pos + 1, pos + m + 1, d) - pos;
    } else {
        if (v > V) return lower_bound(pos + 1, pos + m + 1, d) - pos;
        int x = (V * V - v * v) / a / 2;
        return upper_bound(pos + 1, pos + m + 1, d + x) - pos;
    }
    return m + 1;
}
int find_upper(int d, int v, int a) {
    if (a == 0) {
        if (v <= V) return -1;
        return m;
    } else if (a > 0) {
        return pos[m] >= d ? m : -1;
    } else {
        if (v <= V) return -1;
        int x = (V * V - v * v) / a / 2;
        if (2 * a * x == (V * V - v * v)) return lower_bound(pos + 1, pos + m + 1, d + x) - pos - 1;
        return upper_bound(pos + 1, pos + m + 1, d + x) - pos - 1;
    }
    return -1;
}
int d[maxn], v[maxn], a[maxn];
struct node {
    int l, r;
    node(int l = 0, int r = 0): l(l), r(r){}
    friend bool operator < (const node &x, const node &y) {
        return x.r < y.r;
    }
} e[maxn];
int c[maxn];
int lowbit(int x) {return x & -x;}
void update(int pos, int val = 1) { 
    for (; pos <= m; pos += lowbit(pos)) c[pos] += val;
}
int query(int pos) {
    int ans = 0;
    for (; pos; pos -= lowbit(pos)) ans += c[pos];
    return ans;
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &t);
    while (t--) {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for (int i = 1; i <= n; i++) scanf("%d%d%d", d + i, v + i, a + i);
        for (int i = 1; i <= m; i++) scanf("%d", pos + i);
        k = 0;
        for (int i = 1; i <= n; i++) {
            int l = find_lower(d[i], v[i], a[i]), r = find_upper(d[i], v[i], a[i]);
            if (l <= r) e[++k] = node(l, r);
        }
        int ans = 0;
        sort(e + 1, e + k + 1);
        memset(c, 0, sizeof(c));
        for (int i = 1; i <= k; i++) {
            int cnt = query(e[i].r) - query(e[i].l - 1);
            if (!cnt) {
                ans++;
                update(e[i].r);
            }
        }
        printf("%d %d\n", k, m - ans);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}